package com.banzhi.shop.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.banzhi.shop.MyApp;
import com.banzhi.shop.R;
import com.banzhi.shop.entity.MyRecommend;
import com.banzhi.shop.utils.AndroidUtil;
import com.banzhi.shop.utils.DateUtil;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2017/12/13.
 */

public class RecomAdapter extends BaseQuickAdapter<MyRecommend, BaseViewHolder> {

    public RecomAdapter(@LayoutRes int layoutResId, @Nullable List<MyRecommend> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyRecommend item) {
        if (!AndroidUtil.isEmpty(item.getAvatar()))
            Glide.with(MyApp.getInstance()).load(item.getAvatar()).into((ImageView) helper.getView(R.id.ivHeader));
        helper.setText(R.id.tvName, item.getNickname())
                .setText(R.id.tvRealName, item.getRealname()).setText(R.id.tvRelationship, "1".equals(item.getRelation()) ? "直接推荐" : "间接推荐")
                .setText(R.id.tvSn, item.getOrdersn()).setText(R.id.tvAward, item.getCommission()).setText(R.id.tvTime, DateUtil.getData(item.getAddtime()));
    }
}
